home *** CD-ROM | disk | FTP | other *** search
/ Aminet 38 / Aminet 38 (2000)(Schatztruhe)[!][Aug 2000].iso / Aminet / util / misc / MultiRen.lha / MultiRen / Developers / Template.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-03  |  3.3 KB  |  133 lines

  1. /* Template v1.0 by Deniil 715! rev.#1 for MultiRen
  2.    Made 2000-04-16
  3. */
  4.  
  5. #include<proto/exec.h>
  6. #include<proto/dos.h>
  7. #include<proto/intuition.h>
  8. #include<exec/tasks.h>
  9. #include<intuition/intuition.h>
  10. #include<stdlib.h>
  11. #include<stdio.h>
  12.  
  13. #define _VER "$VER: Template v1.0 by Deniil 715! rev.#1 (2000-04-16)"
  14. #define NUMSTRINGS_FOR_THIS_PLUGIN 1
  15. #define FILE_NAME_LENGTH 512
  16. #define COM_ASK 1
  17. #define COM_EXTRACT 2
  18. #define COM_CONFIGURE 3
  19. #define COM_ABOUT 4
  20. #define COM_QUIT 5
  21. #define ERR_OK 0
  22. #define ERR_NOMEM 1
  23. #define ERR_NOFILE 2
  24. #define ERR_NOSIG 3
  25. #define ERR_NOTIMPL 4
  26. #define ERR_UNKNOWN 5
  27. #define ERR_OTHER 6
  28. #define ERR_WRONGFORMAT 7
  29. #define ERR_FATAL 20
  30.  
  31. struct multiren_plugin {
  32.   long id;
  33.   Task *task;
  34.   long sig;
  35.   short ret;
  36.   char command;
  37.   char numstrings;       /* You will */
  38.   char *stringlist[256]; /* only use */
  39.   char *name;            /* these 3 elements */
  40. };
  41.  
  42. short ask(void);
  43. short extract(void);
  44. short configure(void);
  45. short about(void);
  46. short cleanup(void);
  47. short req(char*,char*);
  48.  
  49. struct multiren_plugin *mrp;
  50.  
  51. int main(int argc,char *argv[]) {
  52.   char sigbit;
  53.   long sig, msig;
  54.   Task *mtask;
  55.   if(DOSBase=(struct DosLibrary*)OpenLibrary("dos.library",0)) {
  56.     if(IntuitionBase=(struct IntuitionBase*)OpenLibrary("shortuition.library",0)) {
  57.       if(argc==2) {
  58.         if(mrp=(struct multiren_plugin*)atol(argv[1])) {
  59.           if(mrp->id==*(long*)"MRPO") {
  60.             if((sigbit=AllocSignal(-1))>=0) {
  61.               sig=1<<sigbit;
  62.               while(1) {
  63.                 switch(mrp->command) {
  64.                 case COM_ASK:
  65.                   mtask=mrp->task;
  66.                   msig=mrp->sig;
  67.                   mrp->ret=ask();
  68.                   SetProgramName(mrp->name);
  69.                   mrp->task=FindTask(0L);
  70.                   mrp->sig=sig;
  71.                   break;
  72.                 case COM_EXTRACT:   mrp->ret=extract(); break;
  73.                 case COM_CONFIGURE: mrp->ret=configure(); break;
  74.                 case COM_ABOUT:     mrp->ret=about(); break;
  75.                 case COM_QUIT:
  76.                   mrp->ret=cleanup();
  77.                   FreeSignal(sigbit);
  78.                   CloseLibrary((struct Library*)DOSBase);
  79.                   Signal(mtask,msig);
  80.                   return 0;
  81.                 default:
  82.                   mrp->ret=ERR_UNKNOWN;
  83.                 }
  84.                 Signal(mtask,msig);
  85.                 Wait(sig);
  86.               }
  87.             }
  88.             else {
  89.               mrp->ret=ERR_NOSIG;
  90.               Signal(mrp->task,mrp->sig);
  91.               return 0;
  92.             }
  93.           }
  94.         }
  95.       }
  96.       CloseLibrary((struct Library*)IntuitionBase);
  97.     }
  98.     CloseLibrary((struct Library*)DOSBase);
  99.   }
  100.   printf("This is a plugin for MultiRen!\n"
  101.          "It is not supposed to be executed manually!\n"
  102.          "Use it through the Renplacer tool in MultiRen instead!\n");
  103.   return ERR_FATAL;
  104. }
  105.  
  106. short ask() {
  107.   mrp->numstrings=NUMSTRINGS_FOR_THIS_PLUGIN;
  108.   mrp->stringlist[0]="<template>";
  109.   mrp->name="<template>";
  110.   return ERR_OK;
  111. }
  112.  
  113. short extract() {
  114.   mrp->stringlist[0]="<template>";
  115.   return ERR_OK;
  116. }
  117.  
  118. short configure() { return ERR_NOTIMPL; }
  119.  
  120. short about() {
  121.   req("About template..","OK");
  122.   return ERR_OK;
  123. }
  124.  
  125. short cleanup() { return ERR_OK; }
  126.  
  127. short req(char *body,char *gads) {
  128.   struct EasyStruct tags;
  129.   tags.es_Title="Test Plugin";
  130.   tags.es_TextFormat=body;
  131.   tags.es_GadgetFormat=gads;
  132.   return EasyRequestArgs(NULL,&tags,NULL,NULL);
  133. }